import request from "@/utils/request";

const USER_BASE_URL = "/api/v1/user";

const MerchantUserAPI = {
  /**
   * 获取商户用户列表
   *
   * @param queryParams 查询参数（可选）
   * @returns 用户列表
   */
  getList(queryParams?: MerchantUserQuery) {
    return request<any, MerchantUserPageVO[]>({
      url: `${USER_BASE_URL}/merchantUser/page`,
      method: "post",
      data: queryParams,
    });
  },
  /**
   * 更新商户用户状态
   *
   * @param id 用户ID
   * @param status 状态
   * @returns 更新结果
   */
  updateStatus(userId: number, status: number) {
    return request<any, any>({
      url: `${USER_BASE_URL}/merchantUser/updateStatus`,
      method: "get",
      params: { userId, status },
    });
  },
  /**
   * 用户下拉选项
   */
  getUsersOptions(params: usersOptionsForm) {
    return request<any, any>({
      url: `/api/v1/users/options`,
      method: "get",
      params,
    });
  },

  /**
   * 修改商户浮动佣金比例
   * @param params
   */
  updateFloatCommissionRatio(params: FloatCommissionRatioForm) {
    return request<any, any>({
      url: `/api/v1/user/merchantUser/floatCommissionRatio`,
      method: "get",
      params,
    });
  },
  /**
   * 获取经纪人列表
   */

  getAgentList(data: any) {
    return request({
      url: `/api/v1/user/merchantUser/consumerAgentPage`,
      method: "post",
      data: data,
    });
  },

  /**
   * 修改经纪人佣金
   */
  updataAgentCommission(params: object) {
    return request({
      url: `/api/v1/user/merchantUser/consumerAgentCommission`,
      method: "get",
      params,
    });
  },
};

export default MerchantUserAPI;

/** 用户查询参数 */
export interface MerchantUserQuery {
  /** 搜索关键字 */
  keywords?: string;
  /** 状态 */
  status?: number;
  /** 页码 */
  pageNum?: number;
  /** 每页条数 */
  pageSize?: number;
}
export interface MerchantUserPageVO {
  list: MerchantUserVO[];
  total: number;
}
export interface MerchantUserVO {
  id: number;
  username: string;
  userType: string;
  nickname: string;
  mobile: string;
  gender: number;
  avatar: string;
  email: string;
  status: number;
  roleNames: string;
  createTime: string;
}

export interface usersOptionsForm {
  types: "";
}

export interface FloatCommissionRatioForm {
  /** 公司ID */
  companyId: number | undefined;

  /** 浮动佣金比例 */
  floatCommissionRatio: string;
}
